// JavaScript Document

var textarea = document.getElementById('textarea');

// les arrays des smileys
var smilies_pop = new Array(':ange:',':angry:',':diable:',':magicien:',':ninja:',':pinch:',':pirate:',':pleure:',':rouge:', ':soleil:', ':waw:', ':zorro:');

var smilies_url = new Array('ange.png','angry.gif','diable.png','magicien.png','ninja.png','pinch.png','pirate.png','pleure.png','rouge.png','soleil.png','waw.png','zorro.png');

function insere(smiley)
{
var champ = window.opener.document.getElementById('textarea');
var scroll = champ.scrollTop;
smiley = ' ' + smiley + ' ';

	if (champ.curseur)
	{
	champ.curseur.text = smiley;
	}
	else if (champ.selectionStart  && champ.selectionEnd )
	{
	var debut = champ.value.substring(0, champ.selectionStart);
	var fin = champ.value.substring(champ.selectionEnd);
	champ.value = debut + smiley + fin;
	champ.focus();
	champ.setSelectionRange(debut.length + smiley.length, champ.value.length - fin.length);
	}
	else
	{
	champ.value  += smiley;
	champ.focus();
	}
champ.scrollTop = scroll;

var champ = window.opener.document.getElementById('textarea');
var div_prev = document.getElementById('prev_'+textarea);
var contenu = champ.value;


}

function remplace(data, search, replace)
{
var temp = data;
var longueur = search.length;
	while (temp.indexOf(search) > -1)
	{
	pos= temp.indexOf(search);
	temp = (temp.substring(0, pos) + replace + temp.substring((pos + longueur), temp.length));
	}
return temp;
}
//zone de saisie -> un textarea 
var champ = document.getElementById('textarea');

//zone de pre-visualisation -> une div
var div_prev = document.getElementById('prev_'+textarea);

